package com.owen.mysql.clickhouse.dynamic.datasource.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.owen.mysql.clickhouse.dynamic.datasource.entity.User;
import com.owen.mysql.clickhouse.dynamic.datasource.mapper.UserMapper;
import com.owen.mysql.clickhouse.dynamic.datasource.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @DS("master")
    @Override
    public List<User> getMysql() {
        return userMapper.selectList(null);
    }

    @DS("slave_1")
    @Override
    public List<User> getClickhouse() {
        return userMapper.selectList(null);
    }
}
